//解析消息
var analysisMsg = cc.Class({
    ctor:function(){

    },

    //解析消息
    onEventTCPSocketRead :function(main,sub,data,size) {
        console.log("========onEventTCPSocketRead========== main = " + main + " sub = " + sub);
        switch (main) {
            case MDM_GP_LOGON: 
                this.onSocketMainLogon(sub, data, size);
                break;
            case MDM_GP_SERVER_LIST:  
                this.onSocketMainServerList(sub, data, size);
                break
            // case MDM_GP_USER_SERVICE: return this.onSocketUserService(sub, data, size);
            // case MDM_GP_USER: return ;//this.onSocketUserServer(sub, data, size);
            case MDM_GP_GET_SERVER: 
                this.onSocketQueryServer(sub, data, size);
                break
            default:
                 break;
        }
    },

   //登陆信息
   onSocketMainLogon :function(sub, data, size){
        switch (sub) {
            //登录成功
            case SUB_GP_LOGON_SUCCESS:
                this.onSocketSubLogonSuccess(data, size);
                break;
            default:
                break;
        }
        return false;
    },

    //登录成功
    onSocketSubLogonSuccess:function (data,dataSize){      
        //消息处理
        var pLogonSuccess = new CMD_GP_LogonResponse();
        //效验数据
        if (dataSize<gCByte.Bytes2Str(pLogonSuccess,data)) return false;
        cc.sys.localStorage.setItem(Key_LoginPsw,  cc.sys.localStorage.getItem(Key_LoginPswT));

        // //变量定义
        // var pGlobalUserData=g_GlobalUserInfo.GetGlobalUserData();
        // var pUserInsureInfo=g_GlobalUserInfo.GetUserInsureInfo();

        // //保存信息
        // gCByte.StrSameMemCopy(pGlobalUserData,pLogonSuccess);

        // //用户成绩
        // pUserInsureInfo.llUserScore=pLogonSuccess.llUserScore;
        // pUserInsureInfo.llUserInsure=pLogonSuccess.llUserInsure;
        ClientNotify.send(CLIENT_NOTIFY_TYPE.LOGIN_RESPONSE, pLogonSuccess);
    },

    // 列表信息
    onSocketMainServerList :function (sub,data,size) {
        switch (sub){
            case SUB_GP_GET_LIST_REQ:
                this.onSocketListKind(data, size);
                break;
            default:
                break;
        }
    },

            //类型信息
    onSocketListKind :function(data, size){
        var Obj = new Object();
        Obj.Arr = new Array();
        Obj.Arr[0] = new tagGameServer();
        var strsize = gCByte.GetSize( Obj.Arr[0]);
        if (size%strsize!=0) return false;
        //变量定义
        var iItemCount=size/strsize;
        if (iItemCount == 0) return true;
        //更新数据
        for (var i=1;i<iItemCount;i++){
            Obj.Arr[i] = new tagGameServer();
        }
        gCByte.Bytes2Str(Obj,data);
        console.log("===============onSocketListKind================" +JSON.stringify(Obj));
        ClientNotify.send(CLIENT_NOTIFY_TYPE.SUB_GP_GET_LIST_REQ, Obj);
        return true;
    },
});